<template>
<div class="box">
  <el-container>
    <el-header >
      <TopHeader></TopHeader>
    </el-header>
    <el-container>
      <el-aside width="200px"><LeftAside @addElementToMain="addElementToMain" @handleMenu="handleMenu"></LeftAside></el-aside>
      <el-main>
        <MainView v-if="this.menu==1" :elements="elements"></MainView>
      <Case2Demo v-if="this.menu==2"></Case2Demo>
        <Case3Demo v-if="this.menu==3"></Case3Demo>
      </el-main>
    </el-container>
  </el-container>
</div>
</template>

<script>
import TopHeader from '../components/TopHeader/TopHeader.vue'
import LeftAside from '../components/LeftAside/LeftAside.vue'
import MainView from '../components/MainView/MainView.vue'
import Case2Demo from "@/components/Case2Demo/Case2Demo.vue"
import Case3Demo from "@/components/Case3Demo/Case3Demo.vue";
export default {
  name: 'KonvaEditor',
  props: {
    msg: String
  },
  components:{
    TopHeader,
    LeftAside,
    MainView,
    Case2Demo,
    Case3Demo,
  },
  data() {
    return {
      elements: [], // 用于存储拖拽的元素
      menu:1
    };
  },
  methods: {
    handleMenu(item){
      this.menu=item
    },
    addElementToMain(elementType) {
      // 这里根据elementType向MainView中的elements数组添加相应的新元素信息
      // 例如，可以创建一个新的对象代表新元素，并推入数组
      console.log(elementType);

      this.elements.push(elementType);
    },
  },
}
</script>

<style scoped src="./KonvaEditor.css">

</style>
